package at.bartinger.gameoflive.otherstuff;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.TextView;
import at.bartinger.gameoflive.R;
import at.bartinger.gameoflive.R.id;
import at.bartinger.gameoflive.R.layout;


public class ZoomDialog extends Dialog implements SeekBar.OnSeekBarChangeListener{

	private SeekBar sb;
	private int prog;
	private ZoomListener l;
	private String title;

	public ZoomDialog(Context context, String title, ZoomListener l) {
		super(context);
		setContentView(R.layout.slider); 
		setTitle(title+": 100%"); 

		this.l = l;
		this.title = title;

		sb = (SeekBar) findViewById(R.id.sb);
		sb.setOnSeekBarChangeListener(this);

		//sb.setProgress(prog);
		sb.setMax(700);

		Button ok = (Button) findViewById(R.id.seekok);
		ok.setOnClickListener(new OKListenerObj());
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		sb.setProgress(prog);
	}

	@Override
	public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
		prog = seekBar.getProgress();
		l.onSeekBarChange(seekBar.getProgress());
		int perc = prog + 100;
		ZoomDialog.this.setTitle(title+": "+perc+ "%");
	}

	@Override
	public void onStartTrackingTouch(SeekBar seekBar) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onStopTrackingTouch(SeekBar seekBar) {
		// TODO Auto-generated method stub

	}

	private class OKListenerObj implements android.view.View.OnClickListener { 

		@Override 
		public void onClick(View v) { 
			l.onOKpressed(prog);
			ZoomDialog.this.dismiss(); 
		}

	}

	public interface ZoomListener { 
		public void onOKpressed(int progress);
		public void onSeekBarChange(int progress);
	}



}
